package com.dq.Week2.day06.homeWork;

import java.util.Random;

//作业：
//创建一个父类：Hero ，属性有 名字，力量，智力，敏捷， 方法有 徒手攻击（攻击力=力量的上下百分之20）
//创建一个子类：战士， 独有的属性，怒气值。独有的方法，英勇打击，（攻击力=力量的上下百分之20*2，消耗20怒气）。
public class Hero {
    private String name;
    private int strong;
    private int intelligence;
    private int speed;

    private int attackPower;

    public  Hero(){}
    public Hero(String name, int strong, int intelligence, int speed) {
        this.name = name;
        this.strong = strong;
        this.intelligence = intelligence;
        this.speed = speed;

    }

    //徒手攻击方法

    public void generalCombat()//普通攻击
    {
        Random random = new Random();
        int attackPowerMAX = (int)(getStrong()*(1+0.2*1));//最大攻击力
        int attackPowerMIN = (int)(getStrong()*(1-0.2*1));//最小攻击力
        this.attackPower = random.nextInt(attackPowerMAX-attackPowerMIN)+attackPowerMIN;//攻击力随机数
        System.out.println(this.name+"使用了普通攻击，攻击力为："+getAttackPower());
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getStrong() {
        return strong;
    }

    public void setStrong(int strong) {
        this.strong = strong;
    }

    public int getIntelligence() {
        return intelligence;
    }

    public void setIntelligence(int intelligence) {
        this.intelligence = intelligence;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getAttackPower() {
        return attackPower;
    }

    public void setAttackPower(int attackPower) {
        this.attackPower = attackPower;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", strong=" + strong +
                ", intelligence=" + intelligence +
                ", speed=" + speed +
                ", attackPower=" + attackPower +
                '}';
    }
}
